﻿using System;
using System.Collections.Generic;
using System.Text;
using Csla.Data;

namespace MinaspetroLibrary.FornecedorPack
{
    [Serializable()]
    public class FornecerdorSetorLigacaoChildInfo : Csla.ReadOnlyBase<FornecerdorSetorLigacaoChildInfo>
    {
        #region Business Properties and Methods

        //declare members

        private Guid _idFornecedor = Guid.NewGuid();

        private Guid _idSetor = Guid.NewGuid();

        private String _setor = String.Empty;

        [System.ComponentModel.DataObjectField(true, true)]
        public Guid IdFornecedor
        {
            get
            {
                return _idFornecedor;
            }
        }

        public Guid IdSetor
        {
            get
            {
                return _idSetor;
            }
        }

        public string Setor
        {
            get
            {
                return _setor;
            }
        }

        protected override object GetIdValue()
        {
            return _idFornecedor.ToString();
        }

        #endregion //Business Properties and Methods

        #region Authorization Rules
        protected override void AddAuthorizationRules()
        {

        }

        #endregion //Authorization Rules

        #region Factory Methods
        internal static FornecerdorSetorLigacaoChildInfo GetFornecerdorSetorChildInfo(SafeDataReader dr)
        {
            return new FornecerdorSetorLigacaoChildInfo(dr);
        }

        private FornecerdorSetorLigacaoChildInfo(SafeDataReader dr)
        {
            Fetch(dr);
        }
        #endregion //Factory Methods

        #region Data Access

        #region Data Access - Fetch
        private void Fetch(SafeDataReader dr)
        {
            FetchObject(dr);
            FetchChildren(dr);

        }

        private void FetchObject(SafeDataReader dr)
        {
            _idFornecedor = new Guid(dr["IdFornecedor"].ToString());
            _idSetor = new Guid(dr["IdSetor"].ToString());
            _setor = dr.GetString("Setor");
        }

        private void FetchChildren(SafeDataReader dr)
        {
        }
        #endregion //Data Access - Fetch
        #endregion //Data Access
    }
}
